package com.ndp.fb.mq.consumer.robot;

import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import com.alibaba.dubbo.config.annotation.Reference;
import com.ndp.ec.core.api.DPAAdPerformService;
import com.ndp.fb.constant.ConfigConst;
import com.ndp.fb.model.fbagent.param.ApiCallBackTarget;
import com.ndp.fb.mq.consumer.AbstractPullConsumer;

/**
 * Created by jacky.cheng on 2016/6/27.
 */
@Component
public class RobotConsumer extends AbstractPullConsumer {
	private final Logger logger = LoggerFactory.getLogger(getClass());
    @Reference
    private DPAAdPerformService dPAAdPerformService;

    @Override
    public String getTopicName() {
        return ConfigConst.MQ_SERVICES_ROBOT_TOPIC;
    }

    @Override
    protected void consume(String tag, String keys, Object message, Map<String, String> equipment) throws Exception {
        logger.debug("RobotConsumer tag >>>> " + tag + " keys >>>" + keys + " message >>> " + message);
        ApiCallBackTarget.Robot target = (ApiCallBackTarget.Robot) ApiCallBackTarget.getTargetType(tag);
        switch (target) {
            case UpdateBudget:
                dPAAdPerformService.updateBudgetCallBack(equipment,(String) message);
                break;
            case StopAd:
                dPAAdPerformService.stopAdCallBack(equipment,(String )message);
                break;
            default:
                break;
        }
    }


}
